<?php
declare (strict_types=1);

namespace app\middleware;

class AllowCrossDomain
{
    /**
     * 处理请求
     * @param \think\Request $request
     * @param \Closure $next
     * @return Response
     */
    public function handle($request, \Closure $next)
    {
        //跨域请求设置
        header("Access-Control-Request-Method:GET,POST");
        header("Access-Control-Allow-Credentials:true");
        header("Access-Control-Allow-Origin: *");
        header("Access-Control-Allow-Headers:X-Token,token,Content-Type, Authorization, Accept, Range, Origin,Token,Lang,lang,source");
        if ($request->isOptions()) {
            die();
        }
        return $next($request);
    }
}
